package edu.whu.rose.clock.ssql.binding;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

public class IntArrayBinding extends TupleBinding {

	public Object entryToObject(TupleInput input) {
		int[] result = new int[input.readInt()];
		for (int i = 0; i < result.length; i++) {
			result[i] = input.readInt();
		}
		return result;
	}
	
	public void objectToEntry(Object object, TupleOutput output) {
		int[] array = (int[])object;
		output.writeInt(array.length);
		for (int i = 0; i < array.length; i++) {
			output.writeInt(array[i]);
		}
	}

}
